from lxml import etree
import re
html = open('./素材/豆瓣.html', 'r', encoding='UTF-8').read()
tree = etree.HTML(html)

li_list = tree.xpath('//ul[@class="cover-col-4 pl20 clearfix" or @class="cover-col-4 clearfix"]/li')
for li in li_list:
    #  获取封面
    print(li.xpath('./a/img/@src')[0])
    # 获取标题
    print(li.xpath('./div[@class="detail-frame"]/h2/a/text()')[0])
    # 获取评分
    print(re.sub('\s','',''.join(li.xpath('./div[@class="detail-frame"]/p[1]//text()'))))
    print(re.sub('\s','',''.join(li.xpath('./div[@class="detail-frame"]/p[2]//text()'))))
    print(re.sub('\s','',''.join(li.xpath('./div[@class="detail-frame"]/p[3]//text()'))))